Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect intent checking for namespace messages #822

Open
wants to merge 1 commit into
base: VSCODE-528-mongodb-copilot
Choose a base branch
from

Conversation

nirinchev
Copy link
Contributor

Description

As I was looking through the namespace buildMessages implementation for something different, I noticed we're using a non-existent field from the chat result metadata to slice the message history. It doesn't appear we have tests for it, which is why it slipped. I restructured the check a little to more explicitly leverage the type system, but perhaps we should have tests to catch future cases.

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@@ -14,7 +14,7 @@
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
"${workspaceFolder}/dist/**/*.js"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change allows the debugger to bind breakpoints we put in the typescript files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Nice add.

@@ -39,7 +39,7 @@ export function getHistoryMessages({
];
if (
responseTypesToSkip.indexOf(
(historyItem.result as ChatResult)?.metadata.intent
(historyItem.result as ChatResult)?.metadata?.intent
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another thing I noticed - not sure if there were cases where it would have manifested, but technically metadata is optional on vscode.ChatResult. Even though we're casting to our ChatResult type, this cast would still succeed if metadata is undefined, making the unconditional access here incorrect.

if (
connectionNames.includes(request.prompt) &&
(context.history[context.history.length - 1] as vscode.ChatResponseTurn)
?.result?.metadata?.askToConnect
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the bug was - askToConnect was replaced with intent, but because this was operating on the vscode.ChatResult.metadata, which is of type any, the compiler didn't complain.

@nirinchev
Copy link
Contributor Author

Going through the Jira tickets, perhaps VSCODE-609 would have actually caught this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants